package com.gexiaobao.pigeon.ui.adapter

import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.gexiaobao.pigeon.R
import com.gexiaobao.pigeon.app.model.bean.GatherListResponse

/**
 * @Author      : hxw
 * @Date        : 2023/2/7 16:15
 * @Describe    :
 */
class GatherPigeonAdapter(data: ArrayList<GatherListResponse.DataList>) :
    BaseQuickAdapter<GatherListResponse.DataList, BaseViewHolder>(R.layout.item_gather_pigeon, data) {

    private var mTotal: Int = 0
    private var mPageNo: Int = 0

    fun setTotal(total: Int, pageNo: Int) {
        mTotal = total
        mPageNo = pageNo
    }

    override fun convert(holder: BaseViewHolder, item: GatherListResponse.DataList) {
        holder.setText(R.id.tv_item_sign_up_pigeon_num, (holder.layoutPosition + 1 + ((mPageNo - 1) * 50)).toString())
        holder.setText(R.id.tv_item_sign_up_pigeon_foster_name, item.fosterName)
        holder.setText(R.id.tv_item_sign_up_pigeon_time, item.gatherTime)
        if (item.ringId.isNotBlank() && item.ringId.length > 8) {
            val start = item.ringId.substring(0, 8)
            val end = item.ringId.substring(8, item.ringId.length)
            holder.setText(R.id.tv_item_sign_up_pigeon_ring_id, start + "\n" + end)
        } else {
            holder.setText(R.id.tv_item_sign_up_pigeon_ring_id, item.ringId)
        }
        holder.setText(R.id.tv_item_sign_up_pigeon_feather_color, item.color)

        holder.setVisible(R.id.ivItemVideoPlayBackFifty, item.videoStatus == 1)

        if (holder.layoutPosition % 2 == 0) {//偶数
            holder.setBackgroundColor(R.id.llItem, ContextCompat.getColor(context, R.color.comm_bg))
        } else {
            holder.setBackgroundColor(R.id.llItem, ContextCompat.getColor(context, R.color.white))
        }
    }
}